<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;


class BankShop_equipment extends Authenticatable
{
    use Notifiable;
	protected $table = 'bankshow_equipment';

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
         'remember_token',
    ];

	// 获取设备及网点名称列表
	public static function getEquipmentBankShop(){
		$bankShopArr = DB::table('bankshow_equipment')
			->leftjoin('bank_show','bankshow_equipment.bank_show_id', '=', 'bank_show.id')
			->where('bankshow_equipment.state','!=',-1)
			->select('bankshow_equipment.*','bank_show.shopName')
			->get()
			->toArray();
		if(!$bankShopArr){
			return array();
		}
		return $bankShopArr;
	}

	// 获取指定网点的设备列表
	public static function getTheOneEquipmentBankShop($bank_id){
		$bankShopArr = DB::table('bankshow_equipment')
			->leftjoin('bank_show','bankshow_equipment.bank_show_id', '=', 'bank_show.id')
			->where('bankshow_equipment.state','!=',-1)
			->where('bankshow_equipment.bank_show_id',$bank_id)
			->select('bankshow_equipment.*','bank_show.shopName')
			->get()
			->toArray();
		if(!$bankShopArr){
			return array();
		}
		return $bankShopArr;
	}

	// 获取可用的设备编号及名称
	public static function getEquipmentEcode(){
		$bankShopArr = DB::table('bankshow_equipment')
			->where('state',1)
			->select('id','e_code','e_name')
			->get()
			->toArray();
		if(!$bankShopArr){
			return array();
		}
		return $bankShopArr;
	}
	// 获取指定网点的设备
	public static function getTheOneBankShopEquipmentEcode($bank_show_id){
		$bankShopArr = DB::table('bankshow_equipment')
			->where('state',1)
			->where('bank_show_id',$bank_show_id)
			->select('id','e_code','e_name')
			->get()
			->toArray();
		if(!$bankShopArr){
			return array();
		}
		return $bankShopArr;
	}

	// 获取指定设备的所有订单
	public static function getShopOrderS($eid){
		$data = DB::table('bankshow_equipment')
			->leftjoin('order', 'bankshow_equipment.e_code', '=', 'order.e_code')
			->where('bankshow_equipment.id',$eid)
			->select('order.*')
			->get()
			->toArray();
		if(!$data){
			return array();
		}
		return $data;
	}


	// 根据id或者名称
	public static function getNameById($id){
		$name = '';
		$name = BankShop_equipment::where('id',$id)->pluck('e_name');
		if($name){
			$name = $name[0];
		}
		return $name;
	}


}
